---
import type { Props } from '@astrojs/starlight/props';
import Default from '@astrojs/starlight/components/Head.astro';
import { getOgImageUrl } from '~/util/getOgImageUrl';

const { isFallback, lang } = Astro.props;

const ogImageUrl = getOgImageUrl(Astro.url.pathname, !!isFallback);
const imageSrc = ogImageUrl ?? '/default-og-image.png';
const canonicalImageSrc = new URL(imageSrc, Astro.site);
---

<Default {...Astro.props}><slot /></Default>
<meta property="og:image" content={canonicalImageSrc} />
<meta name="twitter:image" content={canonicalImageSrc} />

<!-- Algolia docsearch language facet -->
<meta name="docsearch:language" content={lang} />
<meta name="twitter:site" content="astrodotbuild" />

<!-- Fathom analytics -->
<script src="https://cdn.usefathom.com/script.js" data-site="EZBHTSIG" defer></script>
